package com.guoxin.concurrentprogramming.chapter3.threadpool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author guoxin
 * @date 2019/7/16
 */
public class ScheduledExecutorServiceDemo {

    public static void main(String[] args) {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(5);
        Thread thread = new Thread(() -> {
            try {
                Thread.sleep(1000);
                System.out.println(System.currentTimeMillis());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        service.scheduleAtFixedRate(thread,0,2,TimeUnit.SECONDS);
    }
}
